summaryrefslogtreecommitdiffstats
path: root/src/app/(protected)/offices/[officeId].tsx
diff options
context:
space:
mode:
authorAlberto Duarte Delgado <alberto@albertoduarte.com>2026-03-30 15:55:32 +0100
committerAlberto Duarte Delgado <alberto@albertoduarte.com>2026-03-30 15:55:32 +0100
commit31584b4e5a3a551e2ceb15281a38677c39c46e12 (patch)
treeeae47ea7351aa47f25244b42d8d11b69ee9c9d4e /src/app/(protected)/offices/[officeId].tsx
parent6aede83b39f1050b7528b243278a85e5623856be (diff)
Offices logic
Diffstat (limited to 'src/app/(protected)/offices/[officeId].tsx')
-rw-r--r--src/app/(protected)/offices/[officeId].tsx119
1 files changed, 119 insertions, 0 deletions
diff --git a/src/app/(protected)/offices/[officeId].tsx b/src/app/(protected)/offices/[officeId].tsx
index e69de29..77fd610 100644
--- a/src/app/(protected)/offices/[officeId].tsx
+++ b/src/app/(protected)/offices/[officeId].tsx
@@ -0,0 +1,119 @@
+import { Link, useLocalSearchParams } from 'expo-router';
+import { ActivityIndicator, Pressable, StyleSheet, Text, View } from 'react-native';
+import { useOffice } from '@/features/offices/hooks/useOffice';
+
+export default function OfficeDetailScreen() {
+ const params = useLocalSearchParams<{ officeId: string }>();
+ const officeId = typeof params.officeId === 'string' ? params.officeId : undefined;
+
+ const { office, loading, error, reload } = useOffice(officeId);
+
+ if (loading) {
+ return (
+ <View style={styles.center}>
+ <ActivityIndicator size="large" />
+ </View>
+ );
+ }
+
+ if (error || !office) {
+ return (
+ <View style={styles.center}>
+ <Text style={styles.error}>{error ?? 'No se pudo cargar la oficina'}</Text>
+
+ <Pressable style={styles.button} onPress={reload}>
+ <Text style={styles.buttonText}>Reintentar</Text>
+ </Pressable>
+
+ <Link href="/(protected)/offices" asChild>
+ <Pressable style={styles.secondaryButton}>
+ <Text style={styles.buttonText}>Volver a espacios</Text>
+ </Pressable>
+ </Link>
+ </View>
+ );
+ }
+
+ return (
+ <View style={styles.container}>
+ <Text style={styles.title}>{office.name}</Text>
+
+ <View style={styles.card}>
+ <Text style={styles.label}>Ubicación</Text>
+ <Text style={styles.value}>{office.location}</Text>
+
+ <Text style={styles.label}>Capacidad</Text>
+ <Text style={styles.value}>{office.capacity} personas</Text>
+
+ {office.description ? (
+ <>
+ <Text style={styles.label}>Descripción</Text>
+ <Text style={styles.value}>{office.description}</Text>
+ </>
+ ) : null}
+ </View>
+
+ <Link href="/(protected)/reservations/create" asChild>
+ <Pressable style={styles.button}>
+ <Text style={styles.buttonText}>Reservar este espacio</Text>
+ </Pressable>
+ </Link>
+ </View>
+ );
+}
+
+const styles = StyleSheet.create({
+ container: {
+ flex: 1,
+ padding: 16,
+ gap: 16,
+ },
+ center: {
+ flex: 1,
+ alignItems: 'center',
+ justifyContent: 'center',
+ padding: 24,
+ gap: 12,
+ },
+ title: {
+ fontSize: 28,
+ fontWeight: '700',
+ },
+ card: {
+ borderWidth: 1,
+ borderColor: '#ddd',
+ borderRadius: 12,
+ padding: 16,
+ gap: 10,
+ },
+ label: {
+ fontSize: 14,
+ fontWeight: '700',
+ color: '#444',
+ },
+ value: {
+ fontSize: 16,
+ color: '#111',
+ },
+ button: {
+ backgroundColor: '#1f6feb',
+ paddingVertical: 14,
+ borderRadius: 10,
+ alignItems: 'center',
+ },
+ secondaryButton: {
+ backgroundColor: '#555',
+ paddingVertical: 14,
+ paddingHorizontal: 16,
+ borderRadius: 10,
+ alignItems: 'center',
+ },
+ buttonText: {
+ color: '#fff',
+ fontWeight: '600',
+ },
+ error: {
+ color: 'red',
+ textAlign: 'center',
+ },
+});